package com.lgh.ibs.factory;

import com.lgh.ibs.constants.resources.SvnResources;
import com.lgh.ibs.entity.SVN;
import com.lgh.ibs.utils.Base64EncryptUtil;
import com.lgh.ibs.utils.PropertiesUtil;
import com.lgh.ibs.utils.Util;

/**
 * @ClassName: IbsPlusParamFactory 
 * @Description: 插件参数工厂
 * @date 2016年12月21日 下午2:21:02 
 * @author guohao.li
 */
public class IbsPlusParamFactory {
	
	
	public static SVN getSVNInstance() throws Exception{
		SVN svn = new SVN();
		String svnUserName = PropertiesUtil.getValue(SvnResources.SVN_properties.getFileName(), "svnUserName");
		String svnPwd = PropertiesUtil.getValue(SvnResources.SVN_properties.getFileName(), "svnPwd");
		String svnPathVerifyRegex = PropertiesUtil.getValue(SvnResources.SVN_properties.getFileName(), "svnPathVerifyRegex");
		svn.setUserName(svnUserName);
		svn.setPwd(Base64EncryptUtil.customDecipher(svnPwd));
		svn.setSvnPathVerifyRegex(svnPathVerifyRegex);
		
		if(! (!Util.isEmpty(svn.getUserName()) 
				&& !Util.isEmpty(svn.getPwd()) 
				&& !Util.isEmpty(svn.getSvnPathVerifyRegex()))){
			throw new Exception("没有找到SVN配置信息，请到（首选项->IBS工具设置）里进行配置！");
		}
		
		return svn;
	}
}
